<?php
$url='http://zwdtpd.sh.gov.cn/zwdtSW/booking/netreservationItem/listWithPagination4J.do';
$data=json_decode(file_get_contents($url), true);


set_time_limit(0);
error_reporting(E_ALL);
require_once './Classes/PHPExcel.php';

$objPHPExcel = new PHPExcel();

$objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue('A1', '金桥')
;
$index=2;
foreach ($data as $v){
	 
	$orgName=trim($v['stOrgName']);
	if('金桥管委会' == $orgName){
	    $name=trim($v['stItemName']);
	    $objPHPExcel->setActiveSheetIndex(0)
	    ->setCellValue('A'.$index, $name)
	    ->setCellValue('B'.$index, $v['stItemNo'])
	    ->setCellValue('C'.$index, $orgName)
	    ;
	    $index++;
	}
}
 
// Rename worksheet
$objPHPExcel->getActiveSheet()->setTitle('金桥');


// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);


// Redirect output to a client’s web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="金桥.xlsx"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');

// If you're serving to IE over SSL, then the following may be needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
exit;
